<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://localhost:85/?type=catmgr" --><!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>分类管理</title>
<base target="_self" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
<xsl:comment>
html,body { margin:0; padding:0; overflow:hidden}
body,td,th,select,input,button { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.box { padding:1em}
h1.title { font-size:14px; margin:5px 0; padding:0; color:yellow}
form { margin:0; padding:0}
</xsl:comment>
</style>
<script type="text/javascript">
<xsl:comment>
function getCat(cid,pid,defaultcat,obj){
	//alert(cid+"\r\n"+pid+"\r\n"+obj.tagName);	
	var f = document.forms["form1"];
	f.disabled = false;
	f.catname.value = obj.innerText;
	f.pid.value = pid==""?0:pid;
	f.cid.value = cid;
	f.defaultcat.checked = defaultcat;
	var a = document.getElementById("catlist").getElementsByTagName("a");
	for(var i=0; i&lt;a.length; i++){
		a[i].className = "";
	}
	obj.className = "cur";

	f.preid.value = obj.parentNode.previousSibling &amp;&amp; obj.parentNode.previousSibling.firstChild.id || "";
	f.nextid.value = obj.parentNode.nextSibling &amp;&amp; obj.parentNode.nextSibling.firstChild.id || "";
	
}
function moveUP(){
	var f = document.forms["form1"];
	var cid = f.cid.value;
	if(cid=="")return;
	var li = document.getElementById(cid).parentNode;
	if(f.preid.value=="")return;
	if(li.previousSibling){
		li.parentNode.insertBefore(li,li.previousSibling);
		f.nextid.value = f.preid.value;
		
		f.preid.value = li.previousSibling &amp;&amp; li.previousSibling.firstChild.id || "";
		
	}
}
function moveDOWN(){
	var f = document.forms["form1"];
	var cid = f.cid.value;
	if(cid=="")return;
	var li = document.getElementById(cid).parentNode;
	if(f.nextid.value=="")return;
	if(li.nextSibling){
		li.parentNode.insertBefore(li.nextSibling,li);
		f.preid.value = f.nextid.value;
		f.nextid.value = li.nextSibling &amp;&amp; li.nextSibling.firstChild.id || "";
	}
}
function removeCat(){
	var f = document.forms["form1"];
	var cid = f.cid.value;
	if(cid=="")return;
	if(event.shiftKey){		
		if(!confirm("彻底删除此分类吗？\r\n\r\n该分类及其子分类下所有收藏记录都将被永远删除。"))return;
		f.action = "?type=removecatforever";
		setTimeout(function(){document.forms["form1"].submit();},10);
	}else{
		if(!confirm("确定要删除此分类吗？\r\n该分类及其子分类下所有收藏记录都将移动到“未分类”。"))return;
		f.action = "?type=removecat";
		setTimeout(function(){document.forms["form1"].submit();},10);
	}
}
document.onkeydown = function(){
	if("INPUT,SELECT,BUTTON".indexOf(event.srcElement.tagName)>=0){
		return;
	}
	if(event.keyCode==27)window.close();
}
</xsl:comment>
</script>
</head>
<body>

<div class="box">
<h1 class="title">分类管理<input type="hidden" name="callback" id="callback" value="{/root/callback}" /></h1>
<table width="100%" border="1" cellpadding="4" class="catmgr" bordercolor="#607e94">
	<tr>
    	<td valign="top" width="150">
        	<div class="catBox">
        	<ul class="catlist" id="catlist">                
                <xsl:call-template name="getCatTree">
                    <xsl:with-param name="folder" select="/root/favorites" />
                </xsl:call-template>
            </ul>
			<em style="color:gray; display:block; margin-top:1em">“未分类”与“全部收藏”是系统分类，不可修改</em>
            </div>
        </td>
        <td valign="top">
        	<form method="post" name="form1" action="?type=savecatedit" disabled="disabled">
            <input type="hidden" name="cid" /><input type="hidden" name="preid" /><input type="hidden" name="nextid" />
        	<table width="100%" cellpadding="8" cellspacing="0" border="1" frame="void" style="border-collapse:collapse" bordercolor="#506778" rules="rows" class="catedit">
            	<tr>
                	<td><label for="catname">分类名称:</label></td><td><input onfocus="this.select()" type="text" style="width:160px" name="catname" id="catname" /></td>
                </tr>
                <tr>
                	<td><label for="pid">选择父类:</label></td><td>
                    <select style="width:164px" name="pid" id="pid">
                    	<option value="0">根类</option>
                    	<xsl:call-template name="GetCatDropDown">
                        	<xsl:with-param name="folder" select="/root/favorites" />
                            <xsl:with-param name="str" select="string('┝')" />
                        </xsl:call-template>
                    </select></td>
                </tr>
                <tr>
                	<td>分类排序:</td><td><input type="button" value="上移" onclick="moveUP(this)" /> <input type="button" value="下移" onclick="moveDOWN(this)" /><span class="info">只能平级移动</span></td>
                </tr>
                <tr>
                	<td><label for="defaultcat">默认分类:</label></td><td><input type="checkbox" value="1" name="defaultcat" id="defaultcat" /></td>
                </tr>
                <tr>
                	<td colspan="2" align="right"><a href="#" onclick="removeCat();event.returnValue = false;" title="按 Shift 键点击，可以彻底删除分类">删除此分类</a><button type="submit" style=" height:24px; margin-left:1em; vertical-align:middle; font-weight:bold">保存修改</button></td>
                </tr>
            </table></form></td>
    </tr>
</table>
</div>

<script type="text/javascript">
<xsl:comment>
	if(document.getElementById("callback").value==1){
		window.returnValue = 1;
	}
</xsl:comment>
</script>
</body>
</html>

</xsl:template>

<xsl:template name="getCatTree">
    <xsl:param name="folder" />
    <xsl:for-each select="$folder/folder">
        <li>
            <xsl:element name="a">
            	<xsl:attribute name="id"><xsl:value-of select="@guid" /></xsl:attribute>
                <xsl:attribute name="href">javascript:void(0)</xsl:attribute>
                <xsl:attribute name="onclick">getCat('<xsl:value-of select="@guid"/>','<xsl:value-of select="../@guid" />',<xsl:value-of select="@default" />,this)</xsl:attribute>
                <xsl:if test="@default=1">
                <xsl:attribute name="title">默认分类</xsl:attribute>	
                <xsl:attribute name="style">text-decoration:underline</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="@name" />
            </xsl:element><em>(<xsl:value-of select="count(.//fav)" />)</em>
            <xsl:if test=".//folder">
            	<ul>
            	<xsl:call-template name="getCatTree">
                    <xsl:with-param name="folder" select="." />
                </xsl:call-template>
                </ul>
            </xsl:if>
        </li>
    </xsl:for-each>
</xsl:template>

<xsl:template name="GetCatDropDown">
	<xsl:param name="folder" />
    <xsl:param name="str" />
	<xsl:for-each select="$folder/folder">
    	<option value="{@guid}"><xsl:value-of select="$str" /><xsl:value-of select="@name" /></option>
        <xsl:if test="./folder">
        	<xsl:call-template name="GetCatDropDown">
            	<xsl:with-param name="folder" select="." />
                <xsl:with-param name="str" select="concat('　',$str)" />
            </xsl:call-template>
        </xsl:if>
    </xsl:for-each>
</xsl:template>

</xsl:stylesheet>